package clientin

import (
	"context"
	"meta-self/internal/model/entity"
	"meta-self/internal/model/input/form"

	"github.com/gogf/gf/v2/os/gtime"
)

// LicenseKeyCalcPriceInp 计算卡密价格
type LicenseKeyCalcPriceInp struct {
	DurationDays uint   `json:"durationDays" v:"required#有效时长不能为空" dc:"有效时长(天)"`
	Email        string `json:"email" dc:"邮箱(未注册用户)"`
}

func (in *LicenseKeyCalcPriceInp) Filter(ctx context.Context) (err error) {
	return
}

type LicenseKeyCalcPriceModel struct {
	Price float64 `json:"price" dc:"价格"`
}

// LicenseKeyCreateOrderInp 创建卡密订单
type LicenseKeyCreateOrderInp struct {
	DurationDays uint   `json:"durationDays" v:"required#有效时长不能为空" dc:"有效时长(天)"`
	Email        string `json:"email" v:"required#邮箱不能为空" dc:"邮箱(未注册用户)"`
	PayType      string `json:"payType" v:"required#支付方式不能为空" dc:"支付方式"`
	TradeType    string `json:"tradeType" dc:"交易类型"`
	ReturnUrl    string `json:"returnUrl" dc:"支付成功后的跳转地址"`
}

func (in *LicenseKeyCreateOrderInp) Filter(ctx context.Context) (err error) {
	return
}

type LicenseKeyCreateOrderModel struct {
	// 从支付模块中获取的支付参数，包含支付URL等信息
	Order interface{} `json:"order" dc:"支付订单信息"`
}

// LicenseKeyActivateInp 激活卡密
type LicenseKeyActivateInp struct {
	KeyString string `json:"keyString" v:"required#卡密字符串不能为空" dc:"卡密字符串"`
	UserId    int64  `json:"userId" dc:"用户ID"`
	Email     string `json:"email" dc:"邮箱(未注册用户)"`
}

func (in *LicenseKeyActivateInp) Filter(ctx context.Context) (err error) {
	return
}

type LicenseKeyActivateModel struct {
	entity.SysLicenseKeys
}

// LicenseKeyViewInp 获取卡密详情
type LicenseKeyViewInp struct {
	Id        uint64 `json:"id"        dc:"卡密ID"`
	KeyString string `json:"keyString" dc:"卡密字符串"`
}

func (in *LicenseKeyViewInp) Filter(ctx context.Context) (err error) {
	return
}

type LicenseKeyViewModel struct {
	entity.SysLicenseKeys
}

// LicenseKeyListInp 获取卡密列表
type LicenseKeyListInp struct {
	form.PageReq
	KeyString    string        `json:"keyString"    dc:"卡密字符串"`
	Status       string        `json:"status"       dc:"卡密状态"`
	DurationDays uint          `json:"durationDays" dc:"有效时长(天)"`
	ActivatedAt  []*gtime.Time `json:"activatedAt"  dc:"激活时间范围"`
	ExpiresAt    []*gtime.Time `json:"expiresAt"    dc:"过期时间范围"`
	Email        string        `json:"email"        dc:"邮箱"`
}

func (in *LicenseKeyListInp) Filter(ctx context.Context) (err error) {
	return
}

type LicenseKeyListModel struct {
	entity.SysLicenseKeys
	Email string `json:"email" dc:"关联邮箱"`
}

// LicenseKeyHistoryListInp 获取卡密历史记录列表
type LicenseKeyHistoryListInp struct {
	form.PageReq
	LicenseKeyId uint64        `json:"licenseKeyId" dc:"卡密ID"`
	ActionType   string        `json:"actionType"   dc:"操作类型"`
	CreatedAt    []*gtime.Time `json:"createdAt"    dc:"操作时间范围"`
}

func (in *LicenseKeyHistoryListInp) Filter(ctx context.Context) (err error) {
	return
}

type LicenseKeyHistoryListModel struct {
	entity.SysLicenseKeyHistory
}

// LicenseKeyApplyRefundInp 申请卡密退款
type LicenseKeyApplyRefundInp struct {
	Id           uint64 `json:"id" v:"required#卡密ID不能为空" dc:"卡密ID"`
	RefundReason string `json:"refundReason" dc:"退款原因"`
}

func (in *LicenseKeyApplyRefundInp) Filter(ctx context.Context) (err error) {
	return
}

type LicenseKeyApplyRefundModel struct {
	RefundAmount float64 `json:"refundAmount" dc:"退款金额"`
	OrderId      uint64  `json:"orderId" dc:"退款订单ID"`
}
